/** 
* @file vmu_pte.h
* Page Table Entries (PTE) header declarations.
* Provides abstraction interface to aid in managment of PTEs.
* Page Table Entry is what represent PAGE.
* Page is a fixed-length block of memory. This block of memory
* can reside in physical memor (or in harddrive - swaping).
*
* Copyrights 2010 Michal Saman, m.saman@designplus.cz.
* This source code is release under the Apache License 2.0.
* http://www.apache.org/licenses/LICENSE-2.0
*/

#ifndef _VMU_PTE_H
#define _VMU_PTE_H

#include <stdint.h>
#include <mem/pmu.h>

/** Mask for setting parameters of PTE structure */
enum PAGE_PTE_FLAGS {
	PTE_PRESENT				= 1,			/**< Present flag, is Page in memory? */
	PTE_WRITABLE			= 2,			/**< Read/write flag */
	PTE_USER				= 4,			/**< Usermode/Supervisor mode flag */
	PTE_WRITETHOUGH			= 8,			/**< Reserved by intel */
	PTE_NOT_CACHEABLE		= 0x10,			/**< Reserved by intel */
	PTE_ACCESSED			= 0x20,			/**< Acces flag, set by processor */
	PTE_DIRTY				= 0x40,			/**< Dirty flag, set by processor */
	PTE_PAT					= 0x80,				
	PTE_CPU_GLOBAL			= 0x100,
	PTE_LV4_GLOBAL			= 0x200,
	PTE_FRAME				= 0xFFFFF000	/**< Frame address, addr of memory block */
};

/** Page table entry data type representing one PAGE. */
typedef uint32_t pte;

extern void pte_add_attrib(pte *e, uint32_t attrib);
extern void pte_del_attrib(pte *e, uint32_t attrib);
extern void pte_set_frame(pte *e, physical_addr addr);
extern bool pte_is_present(pte e);
extern bool pte_is_writable(pte e);
extern physical_addr pte_get_frame(pte e);

#endif
